package com.by.controller;

import cn.hutool.core.bean.BeanUtil;
import com.by.bean.PriceBean;
import com.by.common.bean.PageBean;
import com.by.common.bean.ResultBean;
import com.by.common.controller.BaseController;
import com.by.query.PriceQuery;
import com.by.service.PriceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author:
 * @date: 2025/2/18
 * @version: 1.01
 * @since: jdk11
 */
@RestController
@RequestMapping("/api")
@Api(tags = "报价管理")
public class PriceController extends BaseController {
    @Autowired
    PriceService priceService;
    @ApiOperation("查询表单信息")
    @GetMapping("/getprice")
    public ResultBean get( Integer id){
        PriceBean page =  priceService.get(id);
        return new ResultBean(200,"表单信息",page);
    }
    @ApiOperation("post表单信息")
    @PostMapping("/postprice")
    public ResultBean<PageBean<List<PriceBean>>> queryByMap(@RequestBody PriceQuery query){
        PageBean page =  priceService.queryByMap(BeanUtil.beanToMap(query));
        return success("post成功",page);
    }
    @ApiOperation("修改报价单")
    @PutMapping("/changepri")
    public ResultBean update(PriceBean priceBean){
        int rs = priceService.update(priceBean);
        return updateResult(rs);
    }
    @ApiOperation("保存报价单")
    @PostMapping("/saveprice")
    public ResultBean save(@RequestBody PriceBean priceBean){
        int rs = priceService.save(priceBean);
        return saveResult(rs);
    }
    @ApiOperation("删除报价单")
    @DeleteMapping("/deletepri/{id}")
    public ResultBean delete(@PathVariable Integer id){
        int rs = priceService.delete(id);
        return deleteResult(rs);
    }
}
